
function Model(prefix, callable) {
    this.onerror = signal();
    this.onlock = signal();
    this.onunlock = signal();
    
    if(callable) {
        
        callable.onerror.add(function(sender, message) {
           
            for(var i = 0; i < this.$.running.length; i++) {
                this.$.running[i]();
            }
            
            this.$.running = [];
            
            this.onerror(message);
            
        }.bind(this));
    }
    
    
    this.$.running = [];

    this.$.emit = function(name, cb, args, message) {

        
        this.onlock();
        workspace.loadMessage.setContent(message ? message: "Realizando la operación");
       
        var current;
        
        
        var terminate = function() {
            this.$.running.splice(this.$.running.indexOf(current),1);
            this.onunlock();

        }.bind(this);
        
        
        
       current = callable.emit(prefix, name, function(retval) {
            terminate();
            cb(retval);
            
            
            
        }, args);

       this.$.running.push(current);

       
    }.bind(this);
}